﻿#ifndef FILESERVICE_H
#define FILESERVICE_H

#include <typesdef.h>
class FileService
{
public:
    FileService();
    //获取目标文件运行平台
    DisassembleMode GetFilePlatFormMachine(LPCWSTR lpFileName);


    //获取文件版本信息,版权信息等
    QString GetFileInformation(QString filePath, enum FileInformation enumInformationCode);
    bool CreateFileImpl(QString qStringFilePath, PHANDLE pFile);
    //解析PE头结构
    void LoadImageHeader(PVOID hModule, PPeStruct pPeStruct);
    //加载指定路径的文件到缓冲区
    bool LoadFileToHeapBuffer(LPCWSTR lpFileName, OUT PVOID* lpFileBuffer);
    //获取指定文件的入口点
    bool GetFileEntryPoint(LPCWSTR lpFileName, PULONG pEntryPoint);
    //获取文件句柄
    NTSTATUS NtOpenFileImpl(QString qStringFilePath, PHANDLE phFile);
    //转换文件映像为内存映像
    VOID MapFileViewToImageView(PULONG_PTR hModuleOfImageView, IN PVOID hModuleOfFileView);
    //遍历导出表
    void IterExportTable(PIMAGE_DATA_DIRECTORY pDataDirectory,ULONG64 hModuleOfImageView);

    //根据导出名称或序号查找导出表
    ULONG SearchFunctionAddressByNameOrByOrigin(
            PIMAGE_DATA_DIRECTORY pDataDirectory
            ,PCNZCH name
            ,ULONG origin
            ,SearchTypeForExportTable serchType
            ,ULONG_PTR hModuleOfImageView
            );

    RtlDosPathNameToNtPathName_UDef RtlDosPathNameToNtPathName_U;
private:
    //获取文件句柄
    NtOpenFileDef NtOpenFile;


};

#endif // FILESERVICE_H
